

#ifndef __QDOCUMENT_H__
#define __QDOCUMENT_H__


#include "QtExt.h"
#include <QtCore/QtCore>


class QSerializer;


class QTEXT_DLL QDocument : public QObject
{
	Q_OBJECT

signals:
	void created();
	void opened();
	void saved();
	void closed();
	void modified();

public:
	QDocument(QObject *parent = 0);
	virtual ~QDocument();

	bool create(const QString &filename);
	bool open(const QString &filename);
	bool save(const QString &filename = "");
	void close();

	void setModifiedFlag(bool flag);
	bool isModified() const
	{
		return mModifiedFlag;
	}

	const QString &location() const
	{
		return mFileLocation;
	}

	const QString &title() const
	{
		return mFileTitle;
	}

	const QString &ext() const
	{
		return mFileExt;
	}

	QFile *fileObject() const
	{
		return mFile;
	}

	virtual bool onCreateDocument() = 0;
	virtual bool onOpenDocument() = 0;
	virtual bool onSaveDocument() = 0;
	virtual void onCloseDocument() = 0;

private:
	QString	mFileLocation;
	QString	mFileTitle;
	QString mFileExt;

	QFile	*mFile;
	bool	mModifiedFlag;
};



#endif	/*__QDOCUMENT_H__*/
